﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Blizzard.Contracts;
using Blizzard.Interceptors;

namespace Blizzard.Test.DataObjectsII
{
    [MapperAttribute(Table = "[DataObjectsII BB]")]
  public class BB : IDataObject
    {
        private Interceptor _interceptor;
        [MapperAttribute(Field = "[MY ID]", IsIdentityColumn = true)]
        public int Id { get; set; }

        private string _name;
        [Mapper(Field = "Name")]
        public string Name
        {
            get
            {
                _interceptor.Intercept(this, "Name", false);
                return _name;
            }
            set
            {
                _interceptor.Intercept(this, "Name", true, _name, value);
                _name = value;
            }
        }

   
        private A _a;
        [Mapper(Field = "[A ID]", Composition = true)]
        public A a
        {
            get
            {
                _interceptor.Intercept(this, "a", false);
                return _a;
            }
            set
            {
                _interceptor.Intercept(this, "a", true, _a, value);
                _a = value;
            }
        }


        private BList<B> _bees;
        [Mapper(JoinTable = "[DataObjectsII B To BB]", MyIdField = "[BB ID]")]
        public BList<B> Bees
        {
            get
            {
                _interceptor.Intercept(this, "Bees", false);
                return _bees;
            }
            set
            {
                _interceptor.Intercept(this, "Bees", true, _bees, value);
                _bees = value;
            }
        }



        public Container.BlizzardManager Manager
        {
            set { _interceptor = new Interceptor(value); }
        }
    }
}
